import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';

const relatedFields = ['oldpk_org', 'oldpk_psncl', 'oldpk_dept', 'oldpk_post', 'oldpk_job'];

export default function resetFormData(pk_psnjob) {
    const {form, orgVal, func_type} = this.props;
    let postData = {
        func_type,
        pk_org: orgVal.refpk,
        pk_psnjob
    };

    return proFetch({
        url: '/nccloud/hrtrn/pub/RecordsPsntransterPsnSelAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                //form.setAllFormValue({'outbatchadd': res.data.outbatchadd});
                const formVals = res.data.outbatchadd.rows[0].values;
                const insertVals = {};
                relatedFields.forEach(item => {
                    insertVals[item] = formVals[item];
                });
                form.setFormItemsValue('outbatchadd', insertVals);
            }
        });
}
